package com.sl.au.repository;
/**
 * 帐台台账
 * zty
 * 2017-02-20
 */
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.EXDEPayAgingAccountInfo;
@Transactional(readOnly = true)
public interface EXDEPayAgingAccountRepository extends JpaRepository<EXDEPayAgingAccountInfo, String>{
	//根据key得数据,
		@Query("select n from EXDEPayAgingAccountInfo n  where n.csuperior = ?1")
		Page<EXDEPayAgingAccountInfo> getexdePayAgingAccountInfo(String superior,Pageable pageable);
		//根据key得数据条数
		@Query("select count(k) from EXDEPayAgingAccountInfo k where k.csuperior = ?1")
		long getCount(String superior);
		//查询的SQL语句
		@Query("select i from EXDEPayAgingAccountInfo i where i.csuperior = ?1 and (i.cdemanderCode like '%'+?2+'%'"
		          +"or i.corderUnit like '%'+?2+'%' or i.careaName like '%'+?2+'%'" 
	          +"or i.cdutyOfficer like '%'+?2+'%')")
		Page<EXDEPayAgingAccountInfo> getexdePayAgingAccountInfo(String superior, String key, Pageable pageable);//注意传值顺序
	//查询获得的条数
		@Query("select count(i) from EXDEPayAgingAccountInfo i where i.csuperior = ?1 and (i.cdemanderCode like '%'+?2+'%'"
		          +"or i.corderUnit like '%'+?2+'%' or i.careaName like '%'+?2+'%'" 
		          +"or i.cdutyOfficer like '%'+?2+'%')")
		long getCount(String superior,String key);//注意顺序
	
	
}
